static int tolua_TypeCast(lua_State* tolua_S)
{
  CCObject* obj = (CCObject*)  tolua_tousertype(tolua_S,1,0);
  const char* type = ((const char*)  tolua_tostring(tolua_S,2,0));
  {
    CCLog("%p %s", obj, type);
    CCObject* tolua_ret = obj;
    int nID = (tolua_ret) ? (int)tolua_ret->m_uID : -1;
    int* pLuaID = (tolua_ret) ? &tolua_ret->m_nLuaID : NULL;
    toluafix_pushusertype_ccobject(tolua_S, nID, pLuaID, (void*)obj,type);
  }
  return 1;
}

void setTouchEnabledAll(CCLayer* l, bool enable){
  l->setTouchEnabled(enable);
  int c = l->getChildrenCount();
  if(c==0){
    return;
  }
  CCArray* children = l->getChildren();
  for(int i=0; i<children->count(); i++){
    CCLayer *child = (CCLayer*)children->objectAtIndex(i);
    child->setTouchEnabled(enable);
    //setTouchEnabledAll(child, enable); 
  } 
}

static int tolua_setTouchEnabledAll(lua_State* tolua_S)
{
  CCLayer* layer = (CCLayer*)  tolua_tousertype(tolua_S,1,0);
  bool bValue = ((bool)  tolua_toboolean(tolua_S,2,0));
  {
    setTouchEnabledAll(layer, bValue);
  }
  return 1;
}
